670A - Holidays - CodeForces Solution


brute force constructive algorithms greedy math *900

Please click on ads to support us..

Python Code:

days = int(input())

if days < 7:
  if days == 6:
    print(1,2)
  elif days <= 5 and days > 1:
    print(0,2)
  else:
    print(0,1)

else:
  
  m1 = days % 7     m2 = days // 7  
  if m1 >= 2:
    maxs = m2 * 2 + 2
  elif m1 == 1:
    maxs = m2 * 2 + 1
  else:
    maxs = m2 * 2

  m3 = m2 * 2
  if m1 == 5:
    print(m3,maxs)
  else:
    mins = m3 + m1 // 5
    print(mins,maxs)

C++ Code:

#include<bits/stdc++.h>
using namespace std;

int n,maxans,minans;
 
int main() 
{
	while(scanf("%d",&n)==1)
	{
		minans=maxans=(n+6)/7*2;
		if(n%7>=1&&n%7<=5)minans=maxans-2;
		if(n%7==6)minans=maxans-1;
		if(n%7==1)maxans--;
		printf("%d %d\n",minans,maxans);	
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches
HRDSEQ Hard Sequence
DRCHEF Doctor Chef
559. Maximum Depth of N-ary Tree
821. Shortest Distance to a Character
1441. Build an Array With Stack Operations
1356. Sort Integers by The Number of 1 Bits
922. Sort Array By Parity II
344. Reverse String
1047. Remove All Adjacent Duplicates In String
977. Squares of a Sorted Array
852. Peak Index in a Mountain Array
461. Hamming Distance
1748. Sum of Unique Elements
897. Increasing Order Search Tree
905. Sort Array By Parity
1351. Count Negative Numbers in a Sorted Matrix
617. Merge Two Binary Trees